<%-- 
    Document   : ShowProduct
    Created on : May 23, 2014, 11:09:38 AM
    Author     : tuanna
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="dao.productDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <%
        String user = session.getAttribute("account").toString();
        productDAO p = new productDAO();
        ResultSet rs = p.getData("select * from Product");
    %>
    <body>
        <font color="blue"><h4>Hi,   <%=user%></h4></font>
        <a href="logout.jsp">Logout</a>
        <form>
            <table border="1">
                <tr>
                    <th>Product ID
                    <th>Product Name
                    <th>Price
                </tr>
                <%while(rs.next()){%>
                <tr>
                    <%
                        String pid = rs.getString(1);
                        String pname = rs.getString(2);
                        float price = rs.getFloat(3);
                    %>
                    
                    <th><%=pid%>
                    <th><%=pname%>
                    <th><%=price%>
                    <th><a href="AddToCart.jsp?pid=<%=pid%>&pname=<%=pname%>&price=<%=price%>">Buy</a>
                </tr>
                <%}%>
            </table>
        </form>
    </body>
</html>
